package cn.tedu.csmall.product.config;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;

/**
 * @author liyang
 * @version 1.0
 * @package cn.tedu.csmall.product.config
 * @file ValidationConfiguration.java
 * @description
 * @time 2024/9/14 下午7:35
 */

@Slf4j
@Configuration
public class ValidationConfiguration {
//    虚字代表返回类型，@Bean注解的功能是让框架自动的执行这个方法
    @Bean
    public javax.validation.Validator validator() {
        return Validation.byProvider(HibernateValidator.class)
                .configure()
                .failFast(true)
                .buildValidatorFactory()
                .getValidator();
    }
}
